<template>
	<div class="form-adapt-container layout-pd">
		<el-card shadow="hover" header="输入必填信息后点击保存">
			<el-form :model="form" size="default" label-width="100px" class="mt35 mb35">
				<el-row :gutter="35">
					<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
						<el-form-item label="项目贯标编号">
							<el-input v-model="form.medListCodg" placeholder="请输入项目贯标编号" clearable></el-input>
						</el-form-item>
					</el-col>
					<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
						<el-form-item label="服务项目名称">
							<el-input v-model="form.servitemName" placeholder="请输入服务项目名称" clearable></el-input>
						</el-form-item>
					</el-col>
					<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
						<el-form-item label="单位">
							<el-input v-model="form.prcunt" placeholder="请输入单位" clearable></el-input>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
		</el-card>
		<el-card shadow="hover" header="录入">
			<el-button @click="save" size="default" class="mt15" type="primary">
				<SvgIcon name="iconfont icon-step" />保存
			</el-button>
		</el-card>
	</div>
</template>

<script lang="ts">
import { toRefs, reactive, defineComponent } from 'vue';
import post from '/@/utils/post'
import { ElMessage } from 'element-plus';

export default defineComponent({
	name: 'serviceInsert',
	setup() {
		const state = reactive({
			form: {
				medListCodg: '',
				servitemName: '',
				prcunt: '',
			}
		});
		const save = async () => {
			let data = {
				medListCodg: state.form.medListCodg,
				servitemName: state.form.servitemName,
				prcunt: state.form.prcunt,
			}
			let result
			try {
				result = await post.postList(data,"http://101.43.6.51:9992/api/his/siMedservice/add")
			} catch (err) {
				result = err
			}
			
			if (result.data == null || result.data.code == null || result.data.code != 0) {
				ElMessage({
					showClose: true,
					duration: 5000,
					message: result.data.message,
					type: 'error',
				})
			} else {
				ElMessage({
					showClose: true,
					duration: 5000,
					message: result.data.message,
					type: 'success',
				})
			}
			
		}

		return {
			save,
			...toRefs(state),
		};
	},
});
</script>
